<h2>Ваши заявки</h2>

<?php print $ORDERS; ?>
<br />

<h2>Сделать заявку</h2>
<?php print form_open('member/orders'); ?>
<table width="100%">
    <tr><td>Количество портов</td><td><input onBlur="calc()" type="text" name="ports" value="" id="ports"></td></tr>
    <tr><td>Количество доп. экземпляров</td><td><input onBlur="calc()" type="text" name="dop" value="" id="dop"></td></tr>
    <tr><td>Бюджет</td><td><input type="text" name="budget" id="sum" value=""></td></tr>
    <tr><td>Описание заявки</td><td><textarea cols="40" rows="7" name="description"></textarea></td></tr>
    <tr><td><input type="button" onClick="calc()" value="Рассчитать бюджет"></td><td><input type="submit" name="order_form_submit" value="Заказать"></td></tr>
    
</table>

<?php print form_close(); ?>

<script language="javascript">
function calc() {
	var ports = parseFloat(document.getElementById("ports").value);
	var dop = parseFloat(document.getElementById("dop").value);
	
	if(isNaN(ports)) {
		document.getElementById("sum").value = '';
		return false;
	}
	if(isNaN(dop))
		dop = 0;
		
	ports = Math.floor(ports);
	dop = Math.floor(dop);
	
	if(ports<=200)
		Sum = ports*75 + 10000 + dop*1120;
	else
		if(ports<=2000)
			Sum = ports*50 + 15000 + dop*1120;
		else
			Sum = ports*40 + 35000 + dop*1120;
	
	Sum = Math.floor(Sum);
	/*Sum = '' + Sum;
	if(Sum.length>6)
		Sum = Sum.substr(0, Sum.length-6) + ' ' + Sum.substr(Sum.length-6, 3) + ' ' + Sum.substr(Sum.length-6, 3);
	else
	if(Sum.length>3)
		Sum = Sum.substr(0, Sum.length-3) + ' ' + Sum.substr(Sum.length-3, 3);
	//Sum+= ' руб.';*/
	document.getElementById("sum").value = Sum;
	
	/*document.getElementById("val_ports").innerHTML = ports;
	document.getElementById("val_dop").innerHTML = dop;
	document.getElementById("val_sum").innerHTML = Sum;*/
	
	/*document.getElementById("sum_S").innerHTML = S;
	document.getElementById("sum_systemclass").innerHTML = systemclass;
	document.getElementById("sum_typevideo").innerHTML = typevideo;
	document.getElementById("sum_count").innerHTML = count;
	document.getElementById("sum_videocenter").innerHTML = videocenter;
	document.getElementById("sum_LAN").innerHTML = LAN;
	document.getElementById("sum_prog").innerHTML = prog;*/
	
	return true;
}
</script>